package com.ctrl.riveradministrator.mvp.presenter;

import android.util.Log;

import com.ctrl.riveradministrator.base.BaseObserver;
import com.ctrl.riveradministrator.base.BasePresenter;
import com.ctrl.riveradministrator.mvp.model.Bulletin;
import com.ctrl.riveradministrator.mvp.model.News;
import com.ctrl.riveradministrator.mvp.view.activity.bulletin.BulletinView;
import com.ctrl.riveradministrator.mvp.view.activity.news.NewsView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class NewsPresenter extends BasePresenter<NewsView> {

    public NewsPresenter(NewsView baseView) {
        super(baseView);
    }

    /**
     * 新闻列表
     *
     * @param pageNumb 索引页数
     * @param pageSize 索引条数
     */
    public void getNews(String pageNumb, String pageSize) {
        Map<String, String> map = new HashMap<>();
        map.put("pageNumb", pageNumb);
        map.put("pageSize", pageSize);
        attachView(apiService.getNews(map), new BaseObserver<News>(getBaseView()) {
            @Override
            public void onSuccess(News model) {
                Log.d("onSuccess",":");
            }

            @Override
            public void onSuccess(List<News> model) {
                getBaseView().showMessage(model);
            }

            @Override
            public void onFailed(String msg) {
                Log.d("onFailed",":"+msg);
            }

        });
    }
}
